{extends 'base/site2.html'}
{block name="page_header"}{include file="common/header.html" inline}{/block}
{block name="page_nav"}{include file="common/slide-nav.html" inline}{/block}
{block name="page_styles"}
<link rel="stylesheet" type="text/css" href="/css/mediation/publiccase/index.css" />
<style>
    :not(.input-group)>.bootstrap-select.form-control:not([class*=col-]){
        width: 100%;
    }
    button {
        outline: none!important;
    }

    .btn-on{
        width: 60px;
        height: 25px;
        margin: 0 3px;
        border-radius: 25px;
        font-size: 14px;
    }
    .btn-on{
        cursor: pointer;
        position: relative;
        border: 1px solid white;
        background-color: #4893f8;
    }
    .btn-on-circle{
        position: absolute;
        width: 15px;
        height: 15px;
        top: 5px;
        left: 5px;
        background-color: rgb(255, 255, 255);
        border-radius: 50%;
        box-shadow: 0 0 10px white;
        transition: all .5s;
    }
    .btn-on-text{
        position: absolute;
        right: 10px;
        line-height: 25px;
        color: white;
        transition: all .5s;
    }
</style>
{/block}
{block name="page_section"}
<div class="sessionPage clearfix">
    <div class="clearfix page-header">
        <div class="left">
            <span class="line"></span>
            <strong class="tit">案件记录</strong>
        </div>
    </div>
    <form method="get" action="" role="validform" enctype="multipart/form-data" class="small-style">
        <div class="form_row">
            <div class="form-group col-lg-3 ui-select">
                <label for="exampleInputName2"  class="col-sm-4 control-label">调解部门:</label>
                <div class="col-sm-7">
                    <select class="form-control selectpicker" name="mediationOrganId">
                        <option class="u144_input_option" {if $query.mediationOrganId == 0}selected="selected"{/if} value="0">全部</option>
                        {foreach from=$mediationOrgan  item=info}
                        <option class="u144_input_option" {if !empty($query.mediationOrganId) &&  $info.id== $query.mediationOrganId}selected="selected"{/if} value="{$info.id}">{$info.name}</option>
                        {/foreach}
                    </select>
                </div>
            </div>
            <div class="form-group col-lg-3 ui-select">
                <label class="col-sm-3 control-label text-nowrap">导入时间:</label>
                <div class="col-sm-7">
                    <input data-ele="date" data-type="daterange" name="add_begin_end" class="form-control" placeholder="请选择" value="{if !empty($smarty.get.add_begin_end)}{$smarty.get.add_begin_end}{/if}" autocomplete="off"/>
                    {* <input data-ele="date" data-type="date" name="add_begin_end" class="form-control" placeholder="请选择" value="{if !empty($query['add_begin_end'])}{$query.add_begin_end}{/if}" autocomplete="off"/>*}
                </div>
            </div>
            <div class="form-group col-lg-3 ui-select">
                <label for="exampleInputName2" class="col-sm-4 control-label">导入批次ID:</label>
                <div class="col-sm-7">
                    <input type="text" class="form-control noempty col-sm-4" value="{$query.importRecordId}" name="importRecordId" placeholder="请输入~">
                </div>
            </div>
            <div class="form-group col-lg-3 ui-select">
                <label for="exampleInputName2" class="col-sm-4 control-label">案件状态:</label>
                <div class="col-sm-7">
                    <select class="form-control selectpicker" name="caseStatus">
                        <option class="u144_input_option" {if $query.caseStatus==4}selected="selected"{/if}
                                value="4">未审核
                        </option>
                        <option class="u144_input_option" {if $query.caseStatus==5}selected="selected"{/if}
                                value="5">审核驳回
                        </option>
                        <option class="u144_input_option" {if $query.caseStatus==1}selected="selected"{/if}
                                value="1">公示中
                        </option>
                        <option class="u144_input_option" {if $query.caseStatus==2}selected="selected"{/if}
                                value="2">关闭公示
                        </option>
                    </select>
                </div>
            </div>
        </div>
        <div class="form_row">

            <div class="form-group col-lg-3 ui-select">
                <label for="exampleInputName2" class="col-sm-4 control-label">当事人:</label>
                <div class="col-sm-7">
                    <input type="text" class="form-control noempty col-sm-4" value="{$query.litigantName}" name="litigantName" placeholder="请输入~">
                </div>
            </div>
            <div class="form-group col-lg-3 ui-select">
                <label for="exampleInputName2" class="col-sm-4 control-label">身份证号:</label>
                <div class="col-sm-7">
                    <input type="text" class="form-control noempty col-sm-4" value="{$query.cardId}" name="cardId" placeholder="请输入后6位/全号~">
                </div>
            </div>
            <div class="form-group col-lg-3 ui-select">
                <div class="col-lg-5">
                    <button class="btn btn-primary col-lg-8 shousuoBtn "><span class="nav-icon glyphicon glyphicon-search" aria-hidden="true" style="margin-right: 2px"></span>查询</button>
                </div>
                <div class="col-lg-5">
                    <a type="button" href="/publiccase" class="btn btn-default col-lg-8 "><span class="nav-icon glyphicon glyphicon-refresh" aria-hidden="true" style="margin-right: 2px"></span>重置</a>
                </div>
            </div>
            <div class="ui-select"></div>
        </div>
    </form>
    <div style="
      width: 95%;
      margin: 0 auto;
      display: flex;
      flex-direction: column;
      overflow-x: scroll;">
        <table class="table table-striped table-bordered table-hover text-nowrap" id="tab">
            <thead>
            <tr>
                <th><input type="checkbox" class="checkall" style="vertical-align: text-bottom"></th>
                <th>导入批次ID</th>
                <th>调解部门</th>
                <th>调解案号</th>
                <th>纠纷类型</th>
                <th>调解状态</th>
                <th>当事人</th>
                <th>身份证号</th>
                <th>资产方</th>
                <th>欠款本金</th>
                <th>标的金额</th>
                <th>是否公示</th>
                <th>导入时间</th>
            </thead>
            <tbody>
            {if $arrList}
            {foreach from=$arrList item=item name=foo}
            <tr>
                <td> <input name="checkItem" class="j-check" type="checkbox" value="{$item.id}"></td>
                <td>{$item.importRecordId}</td>
                <td>
                    {$mediationOrgan[$item.mediationOrganId]['name']}
                </td>
                <td>{$item.mediationNum}</td>
                <td>
                    {$disputeType[$item.disputeType]}
                </td>
                <td>
                    {$caseStatusArr[$item.mediateStatus]}
                </td>
                <td>{$item.litigantName}</td>
                <td>{$item.cardId}</td>
                <td>{$item.assetsName}</td>
                <td>{if $item.debtPrincipal == '0.00'}--{else}{$item.debtPrincipal}{/if}</td>
                <td>{$item.debtTarget}</td>
                <td>
                    {if $item.caseStatus == 1}
                    <p class="btn-on btnon " data-id="{$item.id}" data-type=0>
                        <!-- 圆点 -->
                        <span class="btn-on-circle"></span>
                        <!-- 文字 -->
                        <span class="btn-on-text">是</span>
                    </p>
                    {else}
                    <p class="btn-on btnon" data-id="{$item.id}" data-type=1 style= "background-color: #ccc;">
                        <!-- 圆点 -->
                        <span class="btn-on-circle" style="left: 40px;background-color: #888;box-shadow: 0 0 10px #888;"></span>
                        <!-- 文字 -->
                        <span class="btn-on-text"style="right: 30px;color: #888;">否</span>
                    </p>
                    {/if}
                </td>
                <td>{$item['addTime']|date_format:"%Y-%m-%d %H:%M:%S"}</td>
            </tr>
            {/foreach}
            {/if}
            </tbody>
        </table>
    </div>
    <div class="mr-b20 col-lg-12 pad-no" style="float:none;">
        <input type="button" value="更改调解状态" id='updateMediateStatus' data-toggle="modal" data-target="#export_modal_update" data-id='' class="btn btn-primary">
    </div>
    <div class="clearfix pad-no text-nowrap" style="margin-top: 20px;">
        {include file="base/pagenav.html"  action="/publiccase/index" pagenum=$curPageNum inline}
        <select class="form-control" id="paglimit" style="float:right;margin:0 10px;width: auto;margin-top: -5px;">
            <option value="limit=10" {if $query.limit==10}selected="selected"{/if}>10条/页</option>
            <option value="limit=20" {if $query.limit==20}selected="selected"{/if}>20条/页</option>
            <option value="limit=50" {if $query.limit==50}selected="selected"{/if}>50条/页</option>
            <option value="limit=100" {if $query.limit==100}selected="selected"{/if}>100条/页</option>
        </select>
        <span style="float:right;">共 {$totalnum} 条</span>
    </div>
</div>
<div class="modal fade" id="export_modal_update" tabindex="-1" role="dialog" aria-labelledby="refusal_modal" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered" role="document">
        <div class="modal-content">

            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="exampleModalLabel">更改案件状态</h4>
            </div>
            <div class="modal-body">
                <form id="update_form">
                    <div class="form_dialog form-group col-lg-10 ui-select">
                        <label for="exampleInputName2"  class="col-sm-4 control-label">调解状态:</label>
                        <div class="col-sm-9">
                            <select class="form-control" id="mediateStatus" name="mediateStatus">
                                <option value="" >——请选择——</option>
                                {foreach from=$caseStatusArr key=key item=info}
                                <option class="u144_input_option" value="{$key}">{$info}</option>
                                {/foreach}
                            </select>
                            <input type="hidden" value="" id="update_case_ids" name="update_case_ids">
                        </div>
                    </div>
                    </br>
                    </br>
                </form>
            </div>
            <div class="modal-footer" style="text-align: center;">
                <button type="button" class="btn btn-default" id="fpclosebtn" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary distribution">确定</button>
            </div>


        </div>
    </div>
</div>
{/block}
{block name="page_scripts"}
<script type="text/javascript" src="/js/mediation/publiccase/index.min.js" init="mediation/publiccase/index"></script>
<!-- <script type="text/javascript" src="/js/mediation/publiccase/index.min.js" init="mediation/publiccase/index"></script> -->
<script type="text/javascript">
    function GetQueryString(name){
        var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);

        if(r!=null)return  unescape(r[2]); return null;
    }
    var lock=false,
        lockfas = false;
    $("#updateMediateStatus").on("click",function(){
        var arrbtn = [];
        $(".j-check:checked").each(function (index, ele) {
            //遍历所有复选框，然后取值进行 !非操作
            if ($(this).prop("checked")) {
                arrbtn.push($(this).val());
            }
        })
        if(arrbtn.length==0){
            toastr.error('请选择案件');
            return false;
        }
        $("#chean_num").text(arrbtn.length);
        var ids=arrbtn.toString();
        $("#update_case_ids").val(ids);
        console.log(arrbtn);
        $("#export_modal_withdraw").show();
    });

    $('body')
        .on('click', '.checkall', function(){
            //全选
            $(".j-check,.checkall").prop("checked", $(this).prop("checked"));

        })
        //反选
        .on('change','j-check', function(){
            if ($(".j-check:checked").length == $(".j-check").length) {
                $(".checkall").prop("checked", true);
            } else {
                $(".checkall").prop("checked", false);
            }
        })
        // 案件撤案
        .on('click', '.distribution', function(){
            if(lockfas)return;
            lockfas = true;
            arrcaseid = [];
            if($("#update_case_ids").val()==0){
                toastr.error('请选择案件');
                return false;
            }
            $.ajax({
                url:"/publiccase/updateMediateStatus",
                method:"post",
                data:$("#update_form").serialize(),
                success:function(res){
                    if(res.code==200){
                        lockfas = false;
                        toastr.success("撤案提交成功!");
                        setTimeout(function(){
                            window.location.reload();
                        },2000)
                    }else{
                        lockfas = false;
                        toastr.error(res.message);

                    }
                }
            })
            lockfas = false;

        })
        .on('click','.btnon', function(){
            type = $(this).attr("data-type")
            id = $(this).attr("data-id")
            that = $(this)
            var circle = $(this).find(".btn-on-circle");
            var text = $(this).find(".btn-on-text");
            $.ajax({
                url:"/publiccase/isShow",
                method: "post",
                data: {
                    id: id,
                    showtype: type
                },
                success:function(res){
                    if(res.code==200){
                        if(type == 1){
                            that.removeAttr("style");
                            circle.removeAttr("style");
                            text.removeAttr("style");
                            text.text('是');
                            that.attr("data-type",  0); // 修改状态
                        } else {
                            that.attr("style","background-color: #ccc;")
                            circle.attr("style","left: 40px;background-color: #888;box-shadow: 0 0 10px #888;");
                            text.attr("style","right: 30px;color: #888;");
                            text.text('否');
                            that.attr("data-type",  1); // 修改状态
                        }
                        toastr.success(res.message);
                    }else{
                        toastr.error(res.message);
                    }
                }
            })

        })

            .on('change','#paglimit', function(){

            var mediationOrganId = GetQueryString('mediationOrganId');
            var paglimit = GetQueryString('limit');
            var val =  $(this).val();

            if(!mediationOrganId){
                if(!paglimit){
                    window.location = window.location.href+'?'+val;
                } else{
                    window.location = window.location.href.replace('limit='+paglimit,val);
                }
            }else{
                if(!paglimit){
                    window.location = window.location.href+'&'+val;
                } else{
                    window.location = window.location.href.replace('limit='+paglimit,val);
                }
            }
        })

</script>

{/block}
